package com.manager.base;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.LockMode;

public interface BaseService {
	/**
	 * ----------------------------------JDBCTemplate方法----------------------------------
	 */
	public List queryList(String sql);
	public List queryList(String sql, Object... params);
	
	public int queryInt(String sql);
	public int queryInt(String sql, Object... params);
	
	public boolean queryBoolean(String sql);
	public boolean queryBoolean(String sql, Object... params);
	
	public String queryString(String sql);
	public String queryString(String sql, Object... params);
	
	public Map<String, Object> queryMap(String sql);
	public Map<String, Object> queryMap(String sql, Object... params);
	
	public void add(String sql);
	public void add(String sql, Object... params);
	public void add(String sql, ArrayList params);
	public void add(String table, LinkedHashMap params);
	public int addForPK(String table, LinkedHashMap params);
	
	public void delete(String sql);
	public void delete(String sql, Object... params);
	public void delete(String sql, ArrayList params);
	public void delete(String table, LinkedHashMap whereParams);
	
	public void update(String sql);
	public void update(String sql, Object... params);
	public void update(String sql, ArrayList params);
	public void update(String table, LinkedHashMap setParams, LinkedHashMap whereParams);
	
	//下面的这三个方法可以通用于批量的add, delete, update
	public int executeBatch(String[] sqls);
	public int executeBatch(String sql, Object[][] params);
	public int executeBatch(String sql, ArrayList<ArrayList> params);
	/*
	 * 与其它两个方法差不多，去掉此方法
	 */
//	public int executeSqlBatch(String sql, Object[][] params, int[] sqlTypes, int batchSize);
	
	//Issue a single SQL execute, typically a DDL statement
	public void execute(String sql);
	
	 //call a Stored procedure, return a List<LinkedHashMap>
	public List callProList(String proName, Object ... params);
	
	/**
	 * ----------------------------------HibernateTemplate方法----------------------------------
	 */
	public <T> T getObject(Class<T> entityClass,  Serializable id);
	public <T> T getObject(Class<T> entityClass, Serializable id, LockMode lockMode);
	public Object getObject(String hql, Object... params);
	public List getList(String hql);
	public List getList(String hql, Object... params);
	public List getListTop(String hql, int length);
	public List getListPage(String hql, int offset, int length);
	public List getListBySql(String sql);
	
	public void save(Object entity);
	public void saveOrUpdateAll(Collection entities);
	
	public void delete(Object entity);
	public void delete(Class entityClass, Serializable id);
	public void deleteAll(Collection entities);
	
	public void update(Object entity);
}
